package com.bjpowernode.web.resp.vo;

import com.bjpowernode.util.CommonUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * @author 麦翔盛
 * @ClassName: pageInfo
 * @Package: com.bjpowernode.web.resp.vo
 * @description: 分页模型
 * @date 2022/5/17 21:42
 */
@ApiModel("分页模型")
public class PageInfo {
    @ApiModelProperty(value = "第几页")
    Integer pageNo;
    @ApiModelProperty(value = "每页数量")
    Integer pageSize;
    @ApiModelProperty(value = "总页数")
    Integer totalPage;
    @ApiModelProperty(value = "总条数")
    Integer totalRecord;

    public PageInfo() {
    }

    public PageInfo(Integer pageNo, Integer pageSize, Integer totalRecord) {
        this.pageNo = CommonUtils.getDefPageNo(pageNo);
        this.pageSize = CommonUtils.getDefPageSize(pageSize);
        this.totalRecord = totalRecord;

        this.totalPage = totalRecord / pageSize;
        if (totalRecord % pageSize != 0){
            this.totalPage = (totalRecord / pageSize) + 1;
        }
    }

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public Integer getTotalRecord() {
        return totalRecord;
    }

    public void setTotalRecord(Integer totalRecord) {
        this.totalRecord = totalRecord;
    }
}
